﻿using CMModel;
using System;
using System.Linq;
using System.Windows;

namespace CoffeeManagement
{
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
			controlMain.ManageAccounts += controlMain_ManageAccounts;
            controlMain.ManageSuppliers += controlMain_ManageSuppliers;

			using (CoffeeEntities entities = new CoffeeEntities())
			{
				try
				{
					var a = from phone in entities.SupplierPhones
									where phone.SupplierId == 1
									select phone;
					SupplierPhone p = a.First<SupplierPhone>();
				}
				catch (Exception ex) { }
			}
		}

		private void controlBack_Back(object sender, EventArgs e)
		{
			controlMain.Visibility = Visibility.Visible;
			controlBack.Visibility = Visibility.Hidden;
		}

		private void controlMain_ManageAccounts(object sender, EventArgs e)
		{
			controlMain.Visibility = Visibility.Hidden;
			controlBack.Visibility = Visibility.Visible;
		}

        private void controlMain_ManageSuppliers(object sender, EventArgs e)
        {
            controlMain.Visibility = Visibility.Hidden;
            controlSupllier.Visibility = Visibility.Visible;
        }

        private void controlSupllier_BackClick(object sender, EventArgs e)
        {
            controlSupllier.Visibility = Visibility.Hidden;
            controlMain.Visibility = Visibility.Visible;
        }
	}
}